﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace EbbinghausWord.Controls
{
    public partial class LoadingControl : UserControl
    {
        public LoadingControl()
        {
            InitializeComponent();
        }

        public void Loading(Action startAction, Action endAction)
        {
            Visibility = Visibility.Visible;
            new Thread(() =>
                           {
                               //开始执行
                               startAction();

                               //执行完成
                               this.Dispatcher.BeginInvoke(() =>
                                                               {
                                                                   endAction();
                                                                   this.Visibility = Visibility.Collapsed;
                                                                   progressBar.IsIndeterminate = false;
                                                               });
                           }).Start();
        }
    }
}
